import MyTable from '@/components/MyTable';

import AgentEdit from '@/pages/Act/components/editAgent';
import { findByPageList } from '@/services/agent';
import { ProColumns } from '@ant-design/pro-components';
import { Tag } from 'antd';

interface DataType {
  name: string;
  address: string;
}

const cloneTbale = () => {
  const columns: ProColumns<API.Agent>[] = [
    {
      title: '编号',
      dataIndex: 'index',
      key: 'index',
      valueType: 'indexBorder',
    },
    {
      title: '自动编号',
      dataIndex: 'id',
      key: 'id',
      search: false,
      hideInTable: true,
    },
    {
      title: '名称',
      dataIndex: 'url',
      key: 'url',
      valueType: 'image',
    },
    {
      title: '名称',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: '维语名称',
      dataIndex: 'nameUg',
      key: 'nameUg',
      search: false,
    },
    {
      title: '代理金额',
      dataIndex: 'price',
      key: 'price',
      valueType: 'money',
    },
    {
      title: '等级',
      dataIndex: 'level',
      key: 'level',
      width: 'md',
      valueType: 'digit',
    },
    {
      title: '状态',
      dataIndex: 'state',
      key: 'state',
      width: 'md',
      render: (_: any, row: API.Agent, index: number, action: any) => {
        // eslint-disable-next-line eqeqeq
        return _ === 1 ? (
          <Tag color="green">代理</Tag>
        ) : (
          <Tag color="magenta">普通</Tag>
        );
      },
    },
    {
      title: '操作',
      width: '164px',
      key: 'option',
      valueType: 'option',
      render: (_: any, row: API.Agent, index: number, action: any) => [
        <AgentEdit row={row} text={'编辑'} />,
      ],
    },
  ];

  const toolbar = () => [<AgentEdit text={'新增'} isCard={true} />];
  return (
    <MyTable toolbar={toolbar} columns={columns} request={findByPageList} />
  );
};

export default cloneTbale;
